package com.jsh.erp.service.invoiceItem;

import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Invoice;
import com.jsh.erp.datasource.entities.InvoiceItem;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.InvoiceItemMapper;
import com.jsh.erp.datasource.mappers.InvoiceMapper;
import com.jsh.erp.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 发票子类
 *
 * 该服务类用于业务逻辑的处理，包括发票的增、删、改、查操作
 *
 * @Author yik
 * @Date 2025-01-15
 */
@Service
@Slf4j
public class InvoiceItemService {

    @Resource
    private InvoiceItemMapper itemMapper;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    public int addInvoice(List<InvoiceItem> invoiceItem) {
        return itemMapper.batchInsertItems(invoiceItem);
    }

    public List<InvoiceItem> findDetailsByInvoiceId(Long id) {
        return itemMapper.getItemsByInvoiceId(id);
    }

//    public int updateInvoice(InvoiceItem Invoice) {
//        return itemMapper.updateInvoice(Invoice);
//    }
//
//    public List<Invoice> getAllInvoices(Map<String, String> map) {
//        return itemMapper.findAllInvoices(map);
//    }
//
//    public Long countInvoicesByConditions(Map<String, String> map) {
//        return itemMapper.countInvoicesByConditions(map);
//    }
//
//    public Invoice getInvoiceById(Long id) {
//        return itemMapper.findInvoiceById(id);
//    }
//
//    public int deleteInvoice(Long id) {
//        return itemMapper.deleteInvoice(id);
//    }
}